package com.springcloud.tools.common;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

@ApiModel(value = "Result对象", description = "api操作返回对象")
@Data
@NoArgsConstructor
public class Result<T> {
  @ApiModelProperty(
      value = "返回结果编码",
      name = "code",
      example =
          "200 成功/500 内部错误/501 参数为空/502 用户不存在"
              + "/503 域名不存在/504 告警信息不存在"
              + "/505 参数格式错误/506 注册时，用户已存在"
              + "/507 冻结用户/509 用户验证码错误/510 密码错误"
              + "/511 含有敏感词/520 无权操作 ")
  private int code;

  @ApiModelProperty(value = "返回消息", name = "msg", example = "")
  private String msg;

  @ApiModelProperty(value = "返回数据结构", name = "data", example = "参见返回值 data")
  private T data;

  public Result(int code, String msg, T t) {
    this.code = code;
    this.msg = msg;
    this.data = t;
  }

  public Result(int code, String msg) {
    this.code = code;
    this.msg = msg;
  }
}
